package com.fin.zw.aiqas.entity;

import com.fin.zw.aiqas.enums.ApproveStatus;
import com.fin.zw.aiqas.enums.HitStatus;
import com.fin.zw.aiqas.enums.QualityStatus;
import com.fin.zw.aiqas.enums.ReviewStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(appliesTo = "inspection_detail", comment = "质检结果明细")
@Data
public class InspectionDetail {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty("操作时间")
    @Column(columnDefinition = "datetime comment '操作时间'", name = "created_at")
    private Date createTime;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "task_id", columnDefinition = "bigint(64) COMMENT '任务id'")
    private TaskInfo taskInfo;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "inspect_id", columnDefinition = "bigint(64) COMMENT '质检结果id'")
    private InspectionInfo inspectionInfo;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "depart_id", columnDefinition = "bigint(64) COMMENT '机构id'")
    private Department department;

    @Column(columnDefinition = "varchar(100) COMMENT '客服编号'")
    private String serviceCode;

    @Column(columnDefinition = "varchar(100) COMMENT '客服分机号'")
    private String serviceExt;

    @Column(columnDefinition = "varchar(100) COMMENT '客户手机号'")
    private String customerPhone;

    @Column(columnDefinition = "varchar(15) COMMENT '质检状态'")
    @Enumerated(EnumType.STRING)
    private QualityStatus qualityStatus;

    @Column(columnDefinition = "varchar(20) COMMENT '命中结果'")
    @Enumerated(EnumType.STRING)
    private HitStatus hitStatus;

    @Column(columnDefinition = "varchar(400) COMMENT '命中规则'")
    private String hitRule;

    @Column(columnDefinition = "datetime COMMENT '质检时间'")
    private Date runDate;

    @Column(columnDefinition = "int(10) COMMENT '录音时长'")
    private Integer voiceLength;

    @Column(columnDefinition = "varchar(300) COMMENT '语音url'")
    private String voiceUrl;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "review_user_id", columnDefinition = "bigint(64) COMMENT '复核人'")
    private UserInfo reviewUserInfo;

    @Column(columnDefinition = "datetime COMMENT '复核时间'")
    private Date reviewDate;

    @Column(columnDefinition = "varchar(20) COMMENT '复核状态'")
    @Enumerated(EnumType.STRING)
    private ReviewStatus reviewStatus = ReviewStatus.NOT_CHECK;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "reviewTask_id", columnDefinition = "bigint(64) COMMENT '复核任务ID'")
    private ReviewTask reviewTask;

    @Column(columnDefinition = "varchar(500) COMMENT '复核备注'")
    private String reviewContent;

    @Column(columnDefinition = "varchar(200) COMMENT '复议申请原因'")
    private String reasons;

    @Column(columnDefinition = "varchar(200) COMMENT '复议审批意见'")
    private String opinion;

    @Column(columnDefinition = "datetime COMMENT '复议申请时间'")
    private Date applyTime;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "reconsider_apply_user_id", columnDefinition = "bigint(64) COMMENT '复议申请人'")
    private UserInfo applyUser;

    @Column(columnDefinition = "varchar(20) COMMENT '复议状态'")
    @Enumerated(EnumType.STRING)
    private ApproveStatus reconsiderStatus = ApproveStatus.NO_APPLY;

    @Column(columnDefinition = "datetime COMMENT '复议审批时间'")
    private Date reconsiderDate;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "reconsider_user_id", columnDefinition = "bigint(64) COMMENT '复议审批人员'")
    private UserInfo reconsiderUserInfo;

    @Column(columnDefinition = "varchar(100) COMMENT '质检成功/失败状态'")
    private String detailStatus;

    @Column(columnDefinition = "varchar(500) COMMENT '失败原因'")
    private String failCause;

    @Column(columnDefinition = "varchar(100) COMMENT '文件名称'")
    private String fileName;

}
